/* Layout */
import Layout from '@/layout';
export const studentMngRoutes = {
  path: '/studentMng',
  component: Layout,
  redirect: '/studentMng/studentList',
  name: 'studentMng',
  meta: { title: '学生管理', icon: 'studentMng' },
  alwaysShow: true,
  children: [
    {
      path: 'studentList',
      name: 'studentList',
      component: () => import('@/views/Custom/StudentMng/StudentMng'),
      meta: { title: '学生列表', icon: 'studentList' },
    },

    {
      path: 'addStudent',
      name: 'addStudent',
      component: () => import('@/views/Custom/StudentMng/OperateForm'),
      meta: { title: '新增学员', icon: 'el-icon-s-operation' },
      props({ params: { depAndMajorMenu } }) {
        return { depAndMajorMenu };
      },
      beforeEnter(to, from, next) {
        //第一个参数to，包含的内容是切换后的路由对象，也就是跳转后的路由对象
        //第二个参数from，包含的内容的是切换前的路由对象，也就是跳转前的路由对象
        //第三个参数next()，是否往下执行，执行的话，如果不写的话路由就不会跳转，操作将会终止
        if (from.path.indexOf(['studentList']) != -1) {
          next();
        } else {
          next({
            name: 'studentList',
          });
        }
      },
      hidden: true,
    },
    {
      path: 'editStudent',
      name: 'editStudent',
      component: () => import('@/views/Custom/StudentMng/OperateForm'),
      meta: { title: '编辑学员', icon: 'el-icon-s-operation' },
      props({ params: { editStudentInfo, depAndMajorMenu } }) {
        return { editStudentInfo, depAndMajorMenu };
      },
      beforeEnter(to, from, next) {
        //第一个参数to，包含的内容是切换后的路由对象，也就是跳转后的路由对象
        //第二个参数from，包含的内容的是切换前的路由对象，也就是跳转前的路由对象
        //第三个参数next()，是否往下执行，执行的话，如果不写的话路由就不会跳转，操作将会终止
        if (from.path.indexOf(['studentList']) != -1) {
          next();
        } else {
          next({
            name: 'studentList',
          });
        }
      },
      hidden: true,
    },
  ],
};
